import request from '../utils/Request'

export function login(username, password) {
  const data = {
    principal: username,
    credentials: password
  }
  return request.fetch({
    url: 'login?grant_type=shop_ma',
    method: 'post',
    data: data
  })
}

export function logout() {
  return request.fetch({
    url: 'shopUser/logout',
    method: 'post'
  })
}

export function getInfo() {
  return request.fetch({
    url: 'shopReg/userinfo',
    method: 'get'
  })
}

export function getOpenId(code) {
  return request.fetch({
    url: 'wx/getOpenId?code=' + code,
    method: 'get'
  })
}

export function wxJssdk(currentUrl) {
  return request.fetch({
    url: 'wx/jssdk?currentUrl=' + currentUrl,
    method: 'get'
  })
}

export function saveShopLocation(data) {
  return request.fetch({
    url: 'shopUser/saveShopLocation',
    method: 'post',
    data: data
  })
}

export function getShopClerk() {
  return request.fetch({
    url: 'shopUser/getShopClerk',
    method: 'get'
  })
}
